#include "close_dialog.h"
#include <qdebug.h>
#include <windows.h>
#include <winbase.h>
#include <QTimer>


close_dialog::close_dialog(QWidget* parent)
	: QDialog(parent),
	ui(new Ui::closeDialog())
{
	setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint);
	ui->setupUi(this);
	//ui->min_check_box->setChecked(1);

}

close_dialog::~close_dialog()
{

}

void close_dialog::on_min_check_box_stateChanged(int state)
{
	//is_min_ = state;
	//ui->close_check_box->setChecked(!state);
}

bool close_dialog::nativeEvent(const QByteArray& eventType, void* message, long* result)
{

	if (eventType == "windows_generic_MSG")
	{
		PMSG msg = (PMSG)message;
		
		if (msg->message == WM_NCACTIVATE && msg->wParam ==TRUE) {
			twinkle();
		}

	}

	return false;
}



void close_dialog::on_close_check_box_stateChanged(int state)
{
	//ui->min_check_box->setChecked(!state);
}

void close_dialog::on_rember_check_box_stateChanged(int state)
{
	//is_rem_ = state;
}

void close_dialog::twinkle()
{
	ui->widget->setStyleSheet(QString::fromLocal8Bit("QWidget#widget{background:#ffffff;}"));

	QTimer::singleShot(100, [this]() {
		ui->widget->setStyleSheet(QString::fromLocal8Bit("QWidget#widget{background:#56BFE0;}"));
	});
}
